package cn.reach.rpc.netty.client;

import java.util.Scanner;

/**
 * RPC客户端使用示例
 */
public class NettyClient {
    public static void main(String[] args) {
        // 创建客户端连接到服务器
        NettyRpcClient client = new NettyRpcClient("localhost", 8080);

        try {
            while (true) {
                System.out.println("请输入发送信息: ");
                Scanner scanner = new Scanner(System.in);
                String s = scanner.nextLine();
                String result = client.getResult(5000, s);
                System.out.println("同步获取结果: " + result);
            }
        } catch (Exception e) {
            System.err.println("请求失败: " + e.getMessage());
            e.printStackTrace();
        } finally {
            // 关闭客户端
            client.close();
        }
    }
}